71 research outputs found
Forty hours of declarative programming: Teaching Prolog at the Junior College Utrecht
This paper documents our experience using declarative languages to give
secondary school students a first taste of Computer Science. The course aims to
teach students a bit about programming in Prolog, but also exposes them to
important Computer Science concepts, such as unification or searching
strategies. Using Haskell's Snap Framework in combination with our own
NanoProlog library, we have developed a web application to teach this course.Comment: In Proceedings TFPIE 2012, arXiv:1301.465
A functional specification of effects
This dissertation is about effects and type theory.
Functional programming languages such as Haskell illustrate how to encapsulate side effects using monads. Haskell compilers provide a handful of primitive effectful functions. Programmers can construct larger computations using the monadic return and bind operations.
These primitive effectful functions, however, have no associated deļ¬nition. At best, their semantics are speciļ¬ed separately on paper. This can make it difļ¬cult to test, debug, verify, or even predict the behaviour of effectful computations.
This dissertation provides pure, functional speciļ¬cations in Haskell of several different effects. Using these speciļ¬cations, programmers can test and debug effectful programs. This is particularly useful in tandem with automatic testing tools such as QuickCheck.
The speciļ¬cations in Haskell are not total. This makes them unsuitable for the formal veriļ¬cation of effectful functions. This dissertation overcomes this limitation, by presenting total functional speciļ¬cations in Agda, a programming language with dependent types.
There have been alternative approaches to incorporating effects in a dependently typed programming language. Most notably, recent work on Hoare Type Theory proposes to extend type theory with axioms that postulate the existence of primitive effectful functions. This dissertation shows how the functional speciļ¬cations implement these axioms, unifying the two approaches.
The results presented in this dissertation may be used to write and verify effectful programs in the framework of type theory
A functional specification of effects
This dissertation is about effects and type theory.
Functional programming languages such as Haskell illustrate how to encapsulate side effects using monads. Haskell compilers provide a handful of primitive effectful functions. Programmers can construct larger computations using the monadic return and bind operations.
These primitive effectful functions, however, have no associated deļ¬nition. At best, their semantics are speciļ¬ed separately on paper. This can make it difļ¬cult to test, debug, verify, or even predict the behaviour of effectful computations.
This dissertation provides pure, functional speciļ¬cations in Haskell of several different effects. Using these speciļ¬cations, programmers can test and debug effectful programs. This is particularly useful in tandem with automatic testing tools such as QuickCheck.
The speciļ¬cations in Haskell are not total. This makes them unsuitable for the formal veriļ¬cation of effectful functions. This dissertation overcomes this limitation, by presenting total functional speciļ¬cations in Agda, a programming language with dependent types.
There have been alternative approaches to incorporating effects in a dependently typed programming language. Most notably, recent work on Hoare Type Theory proposes to extend type theory with axioms that postulate the existence of primitive effectful functions. This dissertation shows how the functional speciļ¬cations implement these axioms, unifying the two approaches.
The results presented in this dissertation may be used to write and verify effectful programs in the framework of type theory
A completely unique account of enumeration
How can we enumerate the inhabitants of an algebraic datatype? This paper explores a datatype generic solution that works for all regular types and indexed families. The enumerators presented here are provably both complete and uniqueāthey will eventually produce every value exactly onceāand fairāthey avoid bias when composing enumerators. Finally, these enumerators memoise previously enumerated values whenever possible, thereby avoiding repeatedly recomputing recursive results
FP2: Fully in-Place Functional Programming
As functional programmers we always face a dilemma: should we write purely functional code, or sacrifice purity for efficiency and resort to in-place updates? This paper identifies precisely when we can have the best of both worlds: a wide class of purely functional programs can be executed safely using in-place updates without requiring allocation, provided their arguments are not shared elsewhere. We describe a linear fully in-place (FIP) calculus where we prove that we can always execute such functions in a way that requires no (de)allocation and uses constant stack space. Of course, such a calculus is only relevant if we can express interesting algorithms; we provide numerous examples of in-place functions on datastructures such as splay trees or finger trees, together with in-place versions of merge sort and quick sort. We also show how we can generically derive a map function over any polynomial data type that is fully in-place. Finally, we have implemented the rules of the FIP calculus in the Koka language. Using the Perceus reference counting garbage collection, this implementation dynamically executes FIP functions in-place whenever possibl
A Hoare logic for the state monad: Proof pearl
This pearl examines how to verify functional programs written using the state monad. It uses Coq\u27s Program framework to provide strong specifications for the standard operations that the state monad supports, such as return and bind. By exploiting the monadic structure of such programs during the verification process, it becomes easier to prove that they satisfy their specification
A well-known representation of monoids and its application to the function 'vector reverse': Functional Pearl
Vectorsāor length-indexed listsāare classic example of a dependent type. Yet, most tutorials stay clear of any function on vectors whose definition requires non-trivial equalities between natural numbers to type check. This pearl shows how to write functions, such as vector reverse, that rely on monoidal equalities to be type correct without having to write any additional proofs. These techniques can be applied to many other functions over types indexed by a monoid, written using an accumulating parameter, and even be used to decide arbitrary equalities over monoids āfor free.
- ā¦